import request from "./request";

interface ResultType<T> {
  code: number;
  message: string;
  data: T;
}
interface studentListType {
  class_id: string | number;
  type: number | string;
  username: string;
}
export function queryStudentList(params:studentListType) {
  interface listResultType {
    studentList: [];
    total: number;
  }
  return request<listResultType, ResultType<listResultType>>({
    url: '/student/all',
    method: 'get',
    params,
  })
}
interface addStudentType {
  user_id: string | number;
  class_id: string | number;
}
export function addStudent(data:addStudentType) {
  return request<[], ResultType<[]>>({
    url: '/student/add',
    method: 'post',
    data
  })
}

export function deleteStudent(id:number) {
  return request<[], ResultType<[]>>({
    url: '/student/delete',
    method: 'post',
    data: {
      id
    }
  })
}

interface updateType {
  id: string | number;
  user_id: string | number;
  class_id: string | number;
  type: number;
  username: string;
}
export function updateStudent(data: updateType) {
  return request<[], ResultType<[]>>({
    url: '/student/update',
    method: 'post',
    data: {
      id: data.id,
      user_id: data.user_id,
      class_id: data.class_id,
      type: data.type
    }
  })
}

export function studentNum() {
  return request<Array<object>, ResultType<Array<object>>>({
    url: '/student/num',
    method: 'get',
  })
}
